package com.home.admin.config;

import com.home.common.constants.redis.RedisDateBase;
import com.home.common.redis.RedisUtil;
import com.home.webapp.base.service.InitCacheService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.context.annotation.Configuration;

/**
 * Description: 初始化缓存
 * Created by 王大宸 on 2020-09-28 20:39
 * Created with IntelliJ IDEA.
 */
@Configuration
public class InitCacheRunner implements ApplicationRunner {
    private static final Logger logger = LoggerFactory.getLogger(InitCacheRunner.class);
    @Autowired
    private InitCacheService initCacheService;

    @Override
    public void run(ApplicationArguments args) {
        removeDict();
        initCacheService.initDict();
        logger.info("数据缓存初始化完毕！！！");
    }

    /**
     * 清楚数据字典缓存
     */
    private void removeDict() {
       // RedisUtil.removeAll(RedisDateBase.DEFAULT_DATE_BASE);
        logger.info("数据字典缓存清除完毕...");
    }
}
